import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: GaoBo
 * Date: 2021-04-18
 * Time: 8:25
 */
public class TestDemo {


    public static void main(String[] args) {
        //不规则二维数组
        int[][] array4 = new int[3][];
        array4[0] = new int[3];
        array4[1] = new int[2];
        array4[2] = new int[12];

        for (int i = 0; i < array4.length; i++) {
            for (int j = 0; j < array4[i].length ; j++) {
                System.out.print(array4[i][j]+" ");
            }
            System.out.println();
        }

    }

    public static void main4(String[] args) {
        int[][] array1 = {{1,2,3},{4,5,6}};//2   3
        /*System.out.println(array1[0]);
        System.out.println(array1[1]);*/
        for (int i = 0; i < array1.length; i++) {
            for (int j = 0; j < array1[i].length ; j++) {
                System.out.print(array1[i][j]+" ");
            }
            System.out.println();
        }
        System.out.println("========foreach=======");
        for (int[] arr : array1) {
            for (int x : arr) {
                System.out.print(x+" ");
            }
            System.out.println();
        }
        System.out.println("======Arrays.deepToString()======");
        System.out.println(Arrays.deepToString(array1));
    }

    public static void main3(String[] args) {
        int[][] array1 = {{1,2,3},{4,5,6}};//2   3
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < 3; j++) {
                System.out.print(array1[i][j]+" ");
            }
            System.out.println();
        }
    }


    public static void main2(String[] args) {
        int[][] array1 = {{1,2,3},{4,5,6}};//2   3

        int[][] array2 = new int[][]{{1,2,3},{4,5,6}};

        int[][] array3 = new int[2][3];



    }



    public static void bubbleSort(int[] array) {
        boolean flg = false;
        //用i来表示 趟数  array.length-1
        for (int i = 0; i < array.length-1; i++) {
            flg = false;
            //               j < 4
            //  i = 0     j < 5-1-0
            //  i=1       j < 5-1-1
            for (int j = 0; j < array.length-1-i; j++) {
                if(array[j] > array[j+1]) {
                    int tmp = array[j];
                    array[j] = array[j+1];
                    array[j+1] = tmp;
                    flg = true;
                }
            }
            if(flg == false) {
                break;//结束循环
            }
        }
    }

    public static void reverse(int[] array) {
        int i = 0;
        int j = array.length-1;
        while (i < j) {
            int tmp = array[i];
            array[i] = array[j];
            array[j] = tmp;
            i++;
            j--;
        }
    }

    public static void main1(String[] args) {

        int[] array = new int[10];

        System.out.println(Arrays.toString(array));

        //Arrays.fill(array,99);
        Arrays.fill(array,0,3,99);

        System.out.println(Arrays.toString(array));

       /* int[] array1 = {1,2,3,4,5};
        int[] array2 = {1,2,13,4,5};

        System.out.println(Arrays.equals(array1, array2));
*/
        //array-> [0,3) -> 3
        //System.out.println(Arrays.binarySearch(array,0,2,3));

        /*int ret = Arrays.binarySearch(array, 5);
        System.out.println(ret);
        System.out.println(Arrays.binarySearch(array, 5));
*/
        /*reverse(array);
        System.out.println(Arrays.toString(array));*/
    }
}
